home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / samba-common.config < prev    next >
Text File  |  2009-10-29  |  2KB  |  109 lines

  1. #!/bin/sh -e
  2.  
  3. # Source debconf library.
  4. . /usr/share/debconf/confmodule
  5.  
  6. # Function for grabbing a parameter from an smb.conf file
  7. smbconf_retr() {
  8.     if [ -z "$1" ]; then
  9.         return
  10.     fi
  11.  
  12.     if [ -n "$2" ]; then
  13.         local FILE
  14.         FILE="$2"
  15.     fi
  16.  
  17.     if [ -z "$FILE" ]; then
  18.         return
  19.     fi
  20.  
  21.     sed -n -e"
  22.         s/^[[:space:]]*\[global\]/\[global\]/i
  23.         /^\[global\]/,/^[[:space:]]*\[/ {
  24.             s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
  25.         }" $FILE \
  26.     | tail -n 1
  27. }
  28.  
  29. FILE=/etc/samba/smb.conf
  30.  
  31. db_title "Samba Server"
  32.  
  33. # We ask the question IFF the config contains complex options that could
  34. # cause us to break the config.
  35. if [ -f "$FILE" ] && grep -v dhcp.conf $FILE \
  36.                      | grep -qEi '\\$|^[[:space:]]*include[[:space:]]*='
  37. then
  38.     db_input high samba-common/do_debconf || true
  39.     db_go
  40. else
  41.     db_set samba-common/do_debconf true
  42. fi
  43.  
  44. # If user doesn't want to use debconf to configure Samba the leave...
  45. db_get samba-common/do_debconf || true
  46. if [ "${RET}" = "false" ]; then
  47.     exit 0
  48. fi
  49.  
  50. # User wants to use debconf, let's continue...
  51.  
  52. # Preload any values from the existing smb.conf file
  53. if [ -f $FILE ]; then
  54.     WORKGROUP=`smbconf_retr workgroup`
  55.     if [ "$WORKGROUP" ]; then
  56.         db_set samba-common/workgroup "$WORKGROUP"
  57.     fi
  58.  
  59.     ENCRYPT=`smbconf_retr "encrypt passwords"`
  60.     if [ "$ENCRYPT" ]; then
  61.         ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
  62.         if [ "$ENCRYPT" = "yes" ]; then
  63.             ENCRYPT=true
  64.         elif [ "$ENCRYPT" = "no" ]; then
  65.             ENCRYPT=false
  66.         fi
  67.  
  68.         db_set samba-common/encrypt_passwords "$ENCRYPT"
  69.     fi
  70. fi
  71.  
  72. # Get workgroup name
  73. db_input medium samba-common/workgroup || true
  74. db_go
  75.  
  76. # Use encrypted passwords?
  77. db_input medium samba-common/encrypt_passwords || true
  78. db_go
  79.  
  80. DHCPPRIORITY=medium
  81. #if [ "$DEBCONF_RECONFIGURE" = 1 ] && [ -f /sbin/dhclient3 ]
  82. #if [ -f /sbin/dhclient3 ]
  83. #then
  84. #    DHCPPRIORITY=high
  85. # TODO: see if we can detect that dhcp3-client is *going* to be installed,
  86. # even if it isn't yet.
  87. #elif dpkg-query -W --showformat='${Status}\n' dhcp3-client | grep ???
  88. # unknown ok not-installed ? 
  89. #    DHCPPRIORITY=high
  90. #fi
  91.  
  92. FOUND=false
  93. if [ -f $FILE ]; then
  94.     if grep -q 'include[[:space:]]*=[[:space:]]*/etc/samba/dhcp.conf' $FILE
  95.     then
  96.         FOUND=true
  97.     fi
  98.     db_set samba-common/dhcp $FOUND
  99. fi
  100.  
  101. # we only prompt in one of three cases: the file doesn't exist yet, it
  102. # has the context we need to add our include line, or the include line
  103. # is already present.
  104. if [ ! -f $FILE ] || grep -q -i 'wins server' $FILE || [ "$FOUND" = "true" ];
  105. then
  106.     db_input $DHCPPRIORITY samba-common/dhcp || true
  107.     db_go
  108. fi
  109.